package cn.lanca.gof16_20._18observer.weibocase2;

import java.util.Observable;
import java.util.Observer;
import java.util.Vector;

/**
 * 一：根据现有的jdk Observable/Observer做实现
 * 二：自己实现
 * 三：方法都行
 *
 * @author hongliang.mei
 * @since 2020/12/28 00:54
 */
public class WeiboUser extends Observable implements Observer {

    private String fansName;
    private String followName;


    // 粉丝列表
    public Vector<WeiboUser> fans;
    // 关注列表
    public Vector<WeiboUser> follow;

    public WeiboUser() {
        // 床架用户时初始化关注和被关注列表
        this.fans = new Vector<>();
        this.follow = new Vector<>();
    }

    /**
     * This method is called whenever the observed object is changed. An
     * application calls an <tt>Observable</tt> object's
     * <code>notifyObservers</code> method to have all the object's
     * observers notified of the change.
     *
     * @param o   the observable object.
     * @param arg an argument passed to the <code>notifyObservers</code>
     */
    @Override
    public void update(Observable o, Object arg) {
        // 张三关注李四 在张三的关注列表中添加李四，同时李四在自己的粉丝列表中添加张三
        // 王五关注李四 在王五的关注列表中添加李四，同时李四在自己的粉丝列表中添加王武
        WeiboUser weiboUser = (WeiboUser) o;
        String fansName = weiboUser.getFansName();
        String followName = weiboUser.getFollowName();

    }


    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public String getFansName() {
        return fansName;
    }

    public void setFansName(String fansName) {
        this.fansName = fansName;
    }

    public String getFollowName() {
        return followName;
    }

    public void setFollowName(String followName) {
        this.followName = followName;
    }

    public Vector<WeiboUser> getFans() {
        return fans;
    }

    public void setFans(Vector<WeiboUser> fans) {
        this.fans = fans;
    }

    public Vector<WeiboUser> getFollow() {
        return follow;
    }

    public void setFollow(Vector<WeiboUser> follow) {
        this.follow = follow;
    }
}
